<?php
/**
 * 红包相关
 */
namespace Control;
use Model\RedMod;
use Pub\cache\Cache;

defined('IN_IA') or exit('Access Denied');
class RedControl extends Control
{
    private $Red = null;
    public function __construct()
    {
        parent::__construct();
        $this->Red = new RedMod();
    }

    /**
     * 获取一个红包信息(缓存)
     * @param int $_red_id 红包id
     * @return Array 红包数据
     */
    public function find($_red_id)
    {
        $_data = Cache::get(Cache::RED_DETAIL,array("red_id"=>$_red_id));
        if(!$_data || KUYUAN_DEBUG){
            $_data = $this->Red->findOne(array("id"=>$_red_id),array('uid','title','cover'));
            Cache::set(Cache::RED_DETAIL,$_data,array("red_id"=>$_red_id));
        }
        return $_data;
    }
}